package vn.edu.saigontech.ncms.web.interceptor;

import vn.edu.saigontech.ncms.util.I18n;
import vn.edu.saigontech.ncms.util.Checker;
import vn.edu.saigontech.ncms.web.BaseAction;

import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.AbstractInterceptor;

@SuppressWarnings("serial")
public class I18nInterceptor extends AbstractInterceptor {
	
	public String intercept(ActionInvocation invocation) throws Exception {
		BaseAction action = (BaseAction) invocation.getAction();
		if(Checker.isNull(action.SESSION().getAttribute(I18n.KEY))) {
			action.SESSION().setAttribute(I18n.KEY, new I18n());
		}
		action.RESPONSE().setCharacterEncoding("utf8");
		return invocation.invoke();
	}
}
